(function() {
	var _title_map = {
		"/main": "首页",
		"/goods_list": {
			key: "id",
			value_map: {
				"*": "最新上架",
				"2": "销量最高",
			}
		},
		"/storeinfo": "简介",
		"/cart": "购物车",
		"/goods_details": "商品详情",
		"/pay": "评价管理",
		"/sign_in": {
			key: "id",
			value_map: {
				"*": "用户登录",
				"2": "用户注册"
			}
		}
	};
	Path.on("/:page?", function(_current_location) {
		var title_info = _title_map[Path._current_page];
		if (typeof title_info === "string") {
			App.set("Path.document_title", title_info);
		} else if (typeof title_info === "object") {
			var _val = Path.getQuery(title_info.key);
			App.set("Path.document_title", title_info.value_map[_val] || title_info.value_map["*"]);
		}
		console.log("USER Document title:", App.get("Path.document_title"));
	});


	eventManager.on("!AppReady", function() {
		alert("AppReady")
		App.set("$Event.top.is_menu", function() {
			App.model.toggle("$Cache.top.is_menu");
		});

		App.set("$Event.open_search", function() {
			Path.jump("/searchset.html?q=" + App.get("$Cache.search_text"));
			App.set("$Cache.search_text", "");
		});
	});
}());